#region

using System.Configuration;

#endregion

namespace Jazz.MongoDbProviders
{
    public interface IConnectionStringStore
    {
        string GetConnectionString(string connectionStringName);
    }

    public sealed class ConfigurationManagerConnectionStringStore : IConnectionStringStore
    {
        #region IConnectionStringStore Members

        public string GetConnectionString(string connectionStringName)
        {
            ConnectionStringSettings connectionStringSettings =
                ConfigurationManager.ConnectionStrings[connectionStringName];

            if (connectionStringSettings == null || connectionStringSettings.ConnectionString.Trim() == "")
            {
                return null;
            }

            return connectionStringSettings.ConnectionString;
        }

        #endregion
    }
}